require "lib/timus_access"
require "lib/uva_access"
class ProblemsController < ApplicationController
  before_filter :store_location
  
  def index
    @selected_problems = Problem.paginate :page => params[:page], 
                            :order => 'id ASC', :per_page => 30
  end

  def show
    if(params[:id].nil?)
      redirect_to :action => "index"  
    end
    number = params[:id]
    p = Problem.find_by_id(number)
    if !p.description.nil?
      @text = p.description.text
    else
      @text = p.source.name.constantize::get_description(p.real_identifier)
      temp_des = Description.new
      temp_des.text = @text
      temp_des.problem = p
      temp_des.save
      p.description = temp_des
      p.save
    end
    @name = p.name
    @problem_id = p.id
  end

end
